<?php
$identitas_sekolah = array();
// var_dump($data);
foreach($data->result_array() as $row){
	$identitas_sekolah = $row;
}
// var_dump($identitas_sekolah);

?>
	<!-- BEGIN PAGE -->
	<div class="page-content">
         <!-- BEGIN PAGE CONTAINER-->        
         <div class="container-fluid">
            <!-- BEGIN PAGE HEADER-->
			<div class="row-fluid">
				<div class="span12"> 
					<!-- BEGIN PAGE TITLE & BREADCRUMB-->			
					<h3 class="page-title">
						Form Identitas Sekolah <small> menambah dan mengedit identitas sekolah</small>
					</h3>
					<ul class="breadcrumb">
						<li>
							<i class="icon-cogs"></i>
							Pengaturan		
							<i class="icon-angle-right"></i>
						</li>
						<li>
							<a href="<?php echo base_url()?>identitasSekolah">Identitas Sekolah</a>		
							<i class="icon-angle-right"></i>
						</li>
						<li>Form Identitas Sekolah</li>	
					</ul>
					<!-- END PAGE TITLE & BREADCRUMB-->
				</div>
            </div>
            <!-- END PAGE HEADER-->
            <!-- BEGIN PAGE CONTENT-->          
            <div class="row-fluid">
               <div class="span12">
                  <!-- BEGIN SAMPLE TABLE PORTLET-->
                  <div class="portlet box green">
                     <div class="portlet-title">
                        <div class="caption"><i class="icon-cogs"></i>Form Identitas Sekolah</div>
                     </div>
                     <div class="portlet-body form">
                        <form id="form-identitas_sekolah" class="form-horizontal form-bordered form-row-stripped" action="<?php echo base_url()."identitasSekolah/form/".(isset($identitas_sekolah['identitas_id'])?encode($identitas_sekolah['identitas_id']):'')?>" method="post" enctype="multipart/form-data" >
							<div class="row-fluid">
								<div class="span9">
							<div class="control-group">
                              <label class="control-label">Departemen</label>
							  <input type="hidden" name="data[departemen_id]" value="<?php echo $departemen_id ?>" />
                              <div class="controls">
								<span class="text">
								<?php
									$check = false;
									foreach($departemen->result_array() as $row){
										if($departemen_id == $row['departemen_id']){
											echo '<input class="m-wrap span6"type="text" value="'.$row['nama'].'" readonly="readonly" />';
											$check = true;
										}
									}
									
									if(!$check){
										echo '<input class="m-wrap span6"type="text" value="UMUM" readonly="readonly" />';
									}
								?>
								</span>
                              </div>
							</div>
									<div class="control-group">
								<label class="control-label" >Nama:</label>
								<div class="controls">
									<input class="m-wrap span6" id="nama" type="text" name="data[nama]" value="<?php echo isset($identitas_sekolah['nama'])?$identitas_sekolah['nama']:''?>" required />
								</div>
							</div>
									<div class="control-group">
								<label class="control-label" >Situs:</label>
								<div class="controls">
									<input class="m-wrap span6" id="situs" type="text" name="data[situs]" value="<?php echo isset($identitas_sekolah['situs'])?$identitas_sekolah['situs']:''?>"  required />
								</div>
							</div>
									<div class="control-group">	
										<label class="control-label" >Email:</label>
										<div class="controls">
											<input class="m-wrap span6" id="email" type="text" name="data[email]" value="<?php echo isset($identitas_sekolah['email'])?$identitas_sekolah['email']:''?>"  required />
										</div>
									</div>			
								</div>
								<div class="span3">
									<div class="control-group">
										 <div class="fileupload fileupload-new" data-provides="fileupload" style="margin-top:10px;">
											<div class="fileupload-new thumbnail" style="width: 200px; height: 170px;">
												<?php if(isset($identitas_sekolah['foto'])){?>
												<img src="<?php echo 'data:image/png;base64,'.base64_encode($identitas_sekolah['foto'])?>" alt="" />
												<?php }else{?>
											   <img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&amp;text=no+image" alt="" />
											   <?php } ?>
											</div>
											<div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 200px; max-height: 150px; line-height: 20px;"></div>
											<div>
											   <input type="file" name="userfile" class="default" /></span>
											</div>
										 </div>	
									  </div>
								</div>
							</div>
							
							<div class="control-group">
								<label class="control-label" >Alamat:</label>
								<div class="controls">
									<input class="m-wrap span6" id="alamat1" type="text" name="data[alamat1]" value="<?php echo isset($identitas_sekolah['alamat1'])?$identitas_sekolah['alamat1']:''?>"  required />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" >Telp:</label>
								<div class="controls">
									<input class="m-wrap span6" id="telp1" type="text" name="data[telp1]" value="<?php echo isset($identitas_sekolah['telp1'])?$identitas_sekolah['telp1']:''?>"  required />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" >Fax:</label>
								<div class="controls">
									<input class="m-wrap span6" id="fax1" type="text" name="data[fax1]" value="<?php echo isset($identitas_sekolah['fax1'])?$identitas_sekolah['fax1']:''?>"  required />
								</div>
							</div>
							<div class="control-group">
                              <label class="control-label">Keterangan</label>
                              <div class="controls">
                                 <textarea class="span6 m-wrap" name="data[keterangan]" rows="3"><?php echo isset($identitas_sekolah['keterangan'])?$identitas_sekolah['keterangan']:''?></textarea>
                              </div>
                           </div>
						   <div class="control-group">
                              <label class="control-label">Aktif</label>
                              <div class="controls">
                                 <label class="radio">
                                 <input type="radio" name="data[status]" value=1  <?php echo (isset($identitas_sekolah['status']) &&  $identitas_sekolah['status'] == 1)?'checked="checked"':''?> checked />
                                 Ya
                                 </label>
                                 <label class="radio">
                                 <input type="radio" name="data[status]" value=0 <?php echo (isset($identitas_sekolah['status']) &&  $identitas_sekolah['status'] == 0)?'checked="checked"':''?> />
                                 Tidak
                                 </label>                                
                              </div>
                           </div>
							<div class="form-actions">
							   <button type="submit" class="btn blue"><i class="icon-ok"></i> SIMPAN</button>
							   <a href="<?php echo base_url()?>identitasSekolah" class="btn">BATAL</a>
							</div>
						</form>
                     </div>
                  </div>
                  <!-- END SAMPLE TABLE PORTLET-->
               </div>              
            </div>
           
            <!-- END PAGE CONTENT-->
         </div>
         <!-- END PAGE CONTAINER-->
    </div>
    <!-- END PAGE -->
	<script>
		$(document).ready(function(){
			$("#form-identitas_sekolah").validate(
				{
					errorElement: 'span', //default input error message container
					errorClass: 'help-inline', // default input error message class
					focusInvalid: false, // do not focus the last invalid input
					ignore: "",
					highlight: function (element) { // hightlight error inputs
						$(element)
							.closest('.help-inline').removeClass('ok'); // display OK icon
						$(element)
							.closest('.control-group').removeClass('success').addClass('error'); // set error class to the control group
					},

					unhighlight: function (element) { // revert the change dony by hightlight
						$(element)
							.closest('.control-group').removeClass('error'); // set error class to the control group
					},

					success: function (label) {
						label
							.addClass('valid').addClass('help-inline ok') // mark the current input as valid and display OK icon
						.closest('.control-group').removeClass('error').addClass('success'); // set success class to the control group
					}
				}
			);
			
			
			$('#type').select2({
	            placeholder: "Select an option",
	            allowClear: true
	        });
		});
	</script>